package Stragos.servlet.eventos;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Stragos.excepcion.DAOExcepcion;
import Stragos.modelo.Evento;
import Stragos.negocio.GestionEventos;

/**
 * Servlet implementation class for Servlet: EventoModificarServlet
 */
@WebServlet("/EventoModificarServlet")
public class EventoModificarServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EventoModificarServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub}
		String id = request.getParameter("idEvento");
		String a = request.getParameter("nombre");
		String b = request.getParameter("descripcion");
		
		
		Evento even = new Evento();
		even.setIdEvento(Integer.parseInt(id));
		even.setNombre(a);
		even.setDescripcion(b);
				
		GestionEventos evento = new GestionEventos();
		try {
			evento.modificar(even);
			response.sendRedirect(request.getContextPath()	+ "/EventoBuscarServlet");
		} catch (DAOExcepcion e) {
			System.out.println(e.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}
	}

	

	}


